<?php
/**
 * Created by PhpStorm.
 * User: xsp
 * Date: 2018/4/15
 * Time: 21:51
 */

namespace frontend\controllers;


use common\models\User;
use yii\web\Controller;

class MemberController extends CommonController
{
    public $except = ['login'];
    public $mustLogin = ['logout'];
    public function  actionLogin()
    {
        $this->layout = 'layout2';
        $model = new User();
        if (\Yii::$app->request->isPost)
        {
            $data = \Yii::$app->request->post();
            if($model->login($data))
            {
                $this->redirect(['index/index']);
            }else{
                \Yii::$app->session->setFlash('info','登录失败');
            }
        }
        return $this->render('login',['model'=>$model]);
    }
    public function  actionRegister()
    {

        $this->layout='member';
        return $this->render('register');
    }


    public function actionLogout()
    {
       \Yii::$app->user->logout();

           return $this->redirect(['member/login']);


    }
}